<?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the  Academic Free License (AFL 3.0)
 * that is available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to support@zprofess.com so we can send you a copy immediately.
 *
 * @category   	Prestashop module
 * @package		Customer Point
 * @version 	1.0 (March 2012)
 * @author 		xuanhoapro <xuanhoapro@gmail.com>
 * @copyright   Copyright (c) 2011 ZPROFESS. (http://www.zprofess.com)
 * @license    	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

class ZcustomerPointAdminTab extends AdminTab
{	
	/**
	 * add element for form
	 *
	 * @param string $type type element html render
	 * @param array	$fields
     * @return string html
	 */
	public function addElement($type, $fields = array())
	{	
		if ($type == 'text')
			return $this->renderTextInput($fields);
		elseif ($type == 'color')
			return $this->renderColorPicker($fields);
		elseif ($type == 'select')
			return $this->renderSelect($fields);
		elseif ($type == 'yesno')
			return $this->renderYesNoOption($fields);
	}
	
	/**
	 * display Color Picker
	 *
	 * @param array	$fields
     * @return string html
	 */
	public function renderColorPicker($fields = array())
	{

	}
	
	/**
	 * display TextInput
	 *
	 * @param array	$fields
     * @return string html
	 */
	public function renderTextInput($fields = array())
	{
		if (!($obj = $this->loadObject(true)))
			return;
		return '	
		<label>'.$this->l($fields['label']).'</label>
		<div class="margin-form">
			<input name="'.$fields['name'].'" size="'.$fields['size'].'" id="'.$fields['name'].'" type="text" class="text" value="'.htmlentities($this->getFieldValue($obj, $fields['name']), ENT_COMPAT, 'UTF-8').'"/>
			'.($fields['note'] ? '<p class="clear">'.$this->l($fields['note']).'</p>' : '').'
		</div>
		<div class="clear"></div>';
	}
	
		
	/**
	 * display Select option
	 * 
	 * @param array	$fields
     * @return string html
	 */
	public function renderSelect($fields = array())
	{

	}
	
	/**
	 * display YesNo option radio option
	 * 
	 * @param array	$fields
     * @return string html
	 */
	public function renderYesNoOption($fields = array())
	{
		if (!($obj = $this->loadObject(true)))
			return;
		return '	
		<label>'.$this->l($fields['label']).'</label>
		<div class="margin-form">
			<input type="radio" name="'.$fields['name'].'" id="'.$fields['name'].'_on" value="1" '.($this->getFieldValue($obj, $fields['name']) ? 'checked="checked" ' : '').'/>
			<label class="t" for="'.$fields['name'].'_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
			<input type="radio" name="'.$fields['name'].'" id="'.$fields['name'].'_off" value="0" '.(!$this->getFieldValue($obj, $fields['name']) ? 'checked="checked" ' : '').'/>
			<label class="t" for="'.$fields['name'].'_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
		</div>
		<div class="clear"></div>';
	}
}